40823136

  • Home
    • Site Map
    • reveal
    • blog
  • First
  • About
  • stage1
    • w1
      • 建立網頁
      • 編輯leo
    • w2
      • 討論與影片
      • 圖檔
    • w3
      • 投石機(1)
      • 投石機(2)
      • 投石機(3)
      • 簡報-1
  • stage2
    • w5
      • stage2組員
    • w6
      • heroku
      • 選訂題目
    • w7
      • 自動化生產線(1)-用程式控制機械手臂與調整
    • w8
      • 自動化生產線(2)
    • w9
      • 自動化生產線(3)最終版
    • 簡報-2
  • stage3
    • w10
      • task1
      • task2-1
      • task2-2-python Remote API程式控制機械手臂
      • task2-3
    • w13
      • 第一組線上直播
      • RoboDK
    • w15
      • Video and subtitle translation-1
      • Video and subtitle translation-2
    • w16
      • Onshape 零組件繪製
      • 建立 CoppeliaSim 4.1.0 MTB robot 場景
      • 手臂末端加入 components-gripper-suction pad 吸盤跟鍵盤控制
      • 逆向運動學函式-鍵盤控制與程式迴圈方式
      • Python remote API 逆向運動學函式
  • stage3 專案
    • 自動化(1)
    • 自動化(2)
    • 自動化(3)
    • 心得
  • W18
    • 期末影片
逆向運動學函式-鍵盤控制與程式迴圈方式 << Previous Next >> stage3 專案

Python remote API 逆向運動學函式

api 檔案與程式

import sim as vrep
import sys
import time
import math

vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)

if clientID!= -1:
    print("Connected to remote server")
else:
    print('Connection not successful')
    
    vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot)

def move(j1,j2,j4):
    ret,joint1=vrep.simxGetObjectHandle(clientID,"joint1",vrep.simx_opmode_blocking)
    ret,joint2=vrep.simxGetObjectHandle(clientID,"joint2",vrep.simx_opmode_blocking)
    ret,joint4=vrep.simxGetObjectHandle(clientID,"joint4",vrep.simx_opmode_blocking)
    jointHandle=[joint1,joint2,joint4]
    j=[j1*math.pi/180,j2*math.pi/180,j4*math.pi/180]
    for i in range(3):
        vrep.simxSetJointPosition(clientID,jointHandle[i],j[i],vrep.simx_opmode_oneshot)
        time.sleep(0.5)
def suck():
    vrep.simxSetIntegerSignal(clientID,"active",1,vrep.simx_opmode_oneshot_wait)
def quit():
    vrep.simxSetIntegerSignal(clientID,"active",0,vrep.simx_opmode_oneshot_wait)



while True:
    move(0,0,0)
    quit()
    move(0,0,-2)
    suck()
    
    move(40.9472,-68.978,0)
    quit()
   
    move(40.9472,-68.978,0)
    move(40.9472,-68.978,-2)
    suck()
    move(40.9472,-68.978,0)
    
    move(-158.2529,-89.6799,0)
    quit()
   
    move(-158.2529,-89.6799,0)
    move(-158.2529,-89.6799,-2)
    suck()
    move(-158.2529,-89.6799,0)

心得:

這次作業對我來說非常的有挑戰性,由於我對程式還沒有很熟練,導致在製作時一直發生問題,詢問 40823131跟 40823112,在他們指導下瞭解FOR迴圈的製作與API,讓我了解到哪裡需要加強


逆向運動學函式-鍵盤控制與程式迴圈方式 << Previous Next >> stage3 專案

Copyright © All rights reserved | This template is made with by Colorlib